using Function.SerializedPropertyAttribute;
using SCore.Util;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;


namespace SCore.Function.AutoAnimator
{
#if UNITY_EDITOR
    [CustomEditor(typeof(AutoAnimConfig))]
    public class AutoAnimConfigEditor : ObjectDrawEditor<AutoAnimConfig>
    {
    }
#endif


    [CreateAssetMenu(fileName = "AutoAnimConfig", menuName = "ScriptableObject/AutoAnimConfig", order = 0)]
    public class AutoAnimConfig : SingleScriptableObject<AutoAnimConfig>
    {
        private int _stateItemWidth = 200;
        private int _stateItemHeight = 30;
        [Tooltip("当前创建的索引")] [HideInInspector] public int _curCreatPos = 0;
        [Header("列最大Motion数量")] public int _maxMotionCount = 10;

        [DefinedValues(true, 10, "小", 20, "中", 30, "大")] [Tooltip("StateMach组件的间隔")]
        public int _interval;

        /// <summary>
        /// 得到格子的位置
        /// </summary>
        /// <param name="index">索引</param>
        /// <returns></returns>
        public Vector2 GetPos()
        {
            int x = _curCreatPos / _maxMotionCount;
            int y = _curCreatPos % _maxMotionCount;
            _curCreatPos++;
            return new Vector2((_stateItemWidth + _interval) * x
                , (_stateItemHeight + _interval) * y);
        }

        [ButtonMethod]
        public void CreateAutoConfig()
        {
        }
    }
}